﻿using Aishow.BLL;
using Aishow.Common.Vod;
using Aishow.IBLL;
using Aishow.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Aishow.Website
{
    
        /// <summary>
        /// 视频播放页
        /// </summary>
        public partial class Play : Page
        {
            public string VideoId;
            public int UserId;
            public TBVideos Video;
            public TBUsers Author;
            public GetPlayInfoResult playInfo;
            public bool IsLike;
            public long LikeCount;
            public long DiscussCount;

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    this.VideoId = Request.QueryString["id"];
                    TBUsers user = IdentityManager.ReadUser();
                    this.UserId = user.Id;
                    // 获取发布者信息
                    IVideoManager videoManager = new VideoManager();
                    this.Video = videoManager.GetVideoByVideoId(this.VideoId).ReadResult();
                    this.Author = Video.TBUsers;
                    // 获取播放地址
                    this.playInfo = videoManager.InitPlay(this.VideoId).ReadResult();
                // 点赞
                ILikeManager likeManager = new LikeManager();
                this.IsLike = likeManager.IsLike(VideoId, UserId);
                this.LikeCount = likeManager.Count(VideoId);
                // 评论
                IDiscussManager discussManager = new DiscussManager();
                this.DiscussCount = discussManager.Count(VideoId);
            }
            }
        }
    }

        
    